VPN Status
The commands below are useful once VPN connection has been successfully established.
Get VPN Status
Requests current VPN connection status.
Login required: Yes
CmdProc Code: OVS_CMD_GET_STATUS
Command number: 5
Input: Not required
Response: OVS_NOTIFY_GET_STATUS
- Success
- Failure
OVS_ERR_OK
{
"VPN_Status": 1
}
VPN_Status will contain one of the following values:
- VPN_NOTIFY_CONNECTING
- VPN_NOTIFY_CONNECTED
- VPN_NOTIFY_DISCONNECTED
- VPN_NOTIFY_CONN_FAILED
- VPN_NOTIFY_ABNORMALLY_DISCONNECTED
- VPN_NOTIFY_AUTH
- VPN_NOTIFY_ASSIGNIP
- VPN_NOTIFY_GETCONFIG
data is null
Code sample:
- Java
- Kotlin
- JSON
VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
int state = (Integer)((Map)data).get("VPN_Status");
switch (state) {
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_DISCONNECTED:
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_ABNORMALLY_DISCONNECTED:
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONN_FAILED: {
// Do something when VPN was disconnected
break;
}
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_ASSIGNIP:
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_GETCONFIG:
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_AUTH:
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONNECTING: {
// Do something when VPN was started to connect
break;
}
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONNECTED: {
// Do something when VPN was connected
break;
}
}
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_GET_STATUS, callback);
val callback = object : VPNSDK.CommandNotifyCB {
override fun onNotify(notification: Int, error: Int, data: Any?) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
val state = (data as Map<*, *>)["VPN_Status"] as Int
when (state) {
VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_DISCONNECTED,
VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_ABNORMALLY_DISCONNECTED,
VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONN_FAILED -> {
// Do something when VPN was disconnected
}
VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_ASSIGNIP,
VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_GETCONFIG,
VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_AUTH,
VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONNECTING -> {
// Do something when VPN was started to connect
}
VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONNECTED -> {
// Do something when VPN was connected
}
}
} else {
// Process error
}
}
}
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_GET_STATUS, callback)
VPNSDK.CmdProc("{\"cmd\": 5}");
Get Active VPN Profile
Returns the active VPN connection parameters - server, protocol and port.
Login required: Yes
CmdProc Code: OVS_CMD_GET_CURRENT_PROFILE
Command number: 17
Input: Not required
Response: OVS_NOTIFY_GET_CURRENT_PROFILE
- Success
- Failure
OVS_ERR_OK
data will return
{
"server_ip": "104.192.3.90",
"protocol": "tcp",
"server_port": 1194
}
OVS_ERR_VPN_DISCONNECTED
data is null
Code sample:
- Java
- Kotlin
- JSON
VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_GET_CURRENT_PROFILE, callback);
val callback = object : VPNSDK.CommandNotifyCB {
override fun onNotify(notification: Int, error: Int, data: Any?) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
}
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_GET_CURRENT_PROFILE, callback)
VPNSDK.CmdProc("{\"cmd\": 17}");
Enable IO Counter
Enables of disables IO counter.
Login required: Yes
CmdProc Code: OVS_CMD_SET_IOCOUNT
Command number: 15
Input:
{
"status": true|false
}
Status indicates whether IO counter should be enabled or not.
Response: OVS_NOTIFY_SET_IOCOUNT
- Success
- Failure
OVS_NOTIFY_SET_IOCOUNT
data is null
data is null
While IO counter is enabled then SDK keeps issuing the OVS_NOTIFY_VPN_IOCOUNT notification
Data field of OVS_NOTIFY_VPN_IOCOUNT will have the following structure:
{
"data_in": 0,
"speed_in": 0,
"data_out": 0,
"speed_out": 0
}
Where:
- data_in - Downloaded data amount
- speed_in - Current download speed
- data_out - Uploaded data amount
- speed_out - Current upload speed
Code sample:
- Java
- Kotlin
- JSON
VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_SET_IOCOUNT, callback, true);
val callback = object : VPNSDK.CommandNotifyCB {
override fun onNotify(notification: Int, error: Int, data: Any?) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
}
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_SET_IOCOUNT, callback, true)
VPNSDK.CmdProc("{\"cmd\": 15, \"data\": {\"status\": true}}");